package com.geodroid.action;

import android.graphics.RectF;

import com.geodroid.common.kernel.algos.AlgoJoinPointsSegment;
import com.geodroid.common.kernel.geos.GeoPoint2;
import com.geodroid.common.kernel.geos.GeoSegment;
import com.geodroid.euclidian.Drawable;
import com.geodroid.euclidian.EuclidianView;

public class ActionCreateSegment extends Action {

	private GeoSegment p;
	
	public ActionCreateSegment(int i) {
		super(i) ;
	}

	@Override
	public void process(RectF touchedArea, EuclidianView view) {
		AlgoJoinPointsSegment algo = new AlgoJoinPointsSegment((GeoPoint2) draSel.get(0).getGeo(),(GeoPoint2) draSel.get(1).getGeo()) ;
		this.p = algo.getSegment() ;
		view.addSegment(p) ; 
		isStarted = false; 
		clearSel() ;
	}

	


	/* (non-Javadoc)
	 * @see com.geodroid.action.Action#processDown(android.graphics.RectF, com.geodroid.euclidian.EuclidianView)
	 */
	@Override
	protected void processDown(RectF touchedArea, EuclidianView view) {
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see com.geodroid.action.Action#processMove(android.graphics.RectF, com.geodroid.euclidian.EuclidianView)
	 */
	@Override
	protected void processMove(RectF touchedArea, EuclidianView view) {
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see com.geodroid.action.Action#processUp(android.graphics.RectF, com.geodroid.euclidian.EuclidianView)
	 */
	@Override
	protected void processUp(RectF touchedArea, EuclidianView view) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean validate(Drawable d) {
		return (d.getGeo()) instanceof GeoPoint2 ;
	}


}
